using System;
using System.Collections.Generic;
using System.Text;
using AAM;
using AAM.BIZ;
using System.Web.Security;

namespace CMS.BIZ
{
    [DatabaseTable(TableName = "ForumMessages", TableAlias = "forumMsg")]
    public class BizForumMessage : BizObject
    {

        public static readonly ObjectType ObjectType = new ObjectType("BizForumMessage");

        private int forumMessageID = 0;
        private int forumPostID = 0;
        private string messageTitle = "";
        private string message = "";
        private int? memberID = null;
        private int? parentMessageID = null;
        private DateTime creationDate = DateTime.Now;
        private int? lastModifMemberID = null;
        private DateTime? lastModifDate = null;

        private BizMembershipUser member = null;
        private BizMembershipUser lastModifMember = null;

        public BizForumMessage()
            : base(ObjectType, new object[] { 0 })
        {
        }

        [DatabaseRow(Identity = true, PrimaryKey = true)]
        public int ForumMessageID
        {
            get { return forumMessageID; }
            set { forumMessageID = value; ID[0] = value; }
        }
        [DatabaseRow()]
        public int ForumPostID
        {
            get { return forumPostID; }
            set { forumPostID = value; }
        }
        [DatabaseRow()]
        public string MessageTitle
        {
            get { return messageTitle; }
            set { messageTitle = value; }
        }
        [DatabaseRow()]
        public string Message
        {
            get { return message; }
            set { message = value; }
        }
        [DatabaseRow()]
        public int? MemberID
        {
            get { return memberID; }
            set { memberID = value; }
        }
        [DatabaseRow()]
        public int? ParentMessageID
        {
            get { return parentMessageID; }
            set { parentMessageID = value; }
        }
        [DatabaseRow()]
        public DateTime CreationDate
        {
            get { return creationDate; }
            set { creationDate = value; }
        }
        [DatabaseRow()]
        public int? LastModifMemberID
        {
            get { return lastModifMemberID; }
            set { lastModifMemberID = value; }
        }
        [DatabaseRow()]
        public DateTime? LastModifDate
        {
            get { return lastModifDate; }
            set { lastModifDate = value; }
        }

        public BizMembershipUser Member
        {
            get
            {
                if (member == null && memberID != null)
                {
                    member = (BizMembershipUser)Membership.GetUser(memberID, false);
                }
                return member;
            }
            set 
            {
                if (value == null) memberID = null;
                else memberID = value.MemberID;
                member = value; 
            }
        }
        public BizMembershipUser LastModifMember
        {
            get
            {
                if (lastModifMember == null && lastModifMemberID != null)
                {
                    lastModifMember = (BizMembershipUser)Membership.GetUser(lastModifMemberID, false);
                }
                return lastModifMember;
            }
            set
            {
                if (value == null) lastModifMemberID = null;
                else lastModifMemberID = value.MemberID;
                lastModifMember = value;
            }
        }
    }
}
